var e = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        receive_detail: null,
        info: {},
        goods: {},
        received_info: [],
        received_time: null,
        isReceived: !0,
        showWechatshar: !1,
        mode: null,
        shareInfo: {}
    },
    onLoad: function(e) {
        e.mode && (this.setData({
            mode: e.mode
        }), this.getData());
    },
    getData: function() {
        var t = this, o = "", r = {}, i = new Map([ [ "creat", "plugin.warehouse.frontend.controllers.gift.give" ], [ "receiving", "plugin.warehouse.frontend.controllers.gift.records.detail" ], [ "getgift", "plugin.warehouse.frontend.controllers.gift.records.detail" ], [ "give", "plugin.warehouse.frontend.controllers.gift.give.receive" ] ]);
        i.has(this.data.mode) && (o = i.get(this.data.mode)), "creat" == this.data.mode ? (r = {
            goods_id: this.options.gid,
            nums: Number(this.options.nums),
            share_num: this.options.sNum
        }, this.setData({
            isReceived: !1
        })) : "receiving" == this.data.mode || "getgift" == this.data.mode ? r = {
            gift_type: "getgift" == this.data.mode ? "get" : "",
            records_id: this.options.records_id
        } : "give" == this.data.mode && (r = {
            gift_key: this.options.id
        });
        var d = a.getNetAddresss(o);
        a._postNetWork({
            url: d,
            data: r,
            success: function(a) {
                var o = a.data;
                1 == o.result ? (t.data.shareInfo.title = o.data.share_info && o.data.share_info.title || "赠送礼物", 
                t.data.shareInfo.imgUrl = o.data.share_info && o.data.share_info.thumb || null, 
                "creat" == t.data.mode ? (t.setInfo(o.data.info, o.data.goods), t.data.shareInfo.otherParam = "gapid=".concat(o.data.mark_id)) : "receiving" == t.data.mode || "getgift" == t.data.mode ? (t.setInfo(o.data.record.has_one_give, o.data.record.has_one_goods, o.data.record.has_many_receive), 
                t.setData(e({
                    receive_detail: o.data.detail,
                    received_time: o.data.record.updated_at
                }, "goods.nums", o.data.record.goods_num)), 0 == o.data.record.status && (t.data.shareInfo.otherParam = "gapid=".concat(o.data.record.mark_id), 
                t.setData({
                    isReceived: !1
                })), t.data.shareInfo.otherParam = "records_id=".concat(t.options.records_id)) : "give" == t.data.mode && (t.setInfo(o.data.record.has_one_give, o.data.record.has_one_goods, o.data.record.has_many_receive), 
                t.setData(e({
                    receive_detail: o.data.detail,
                    received_time: o.data.updated_at
                }, "goods.nums", o.data.record.goods_num)), t.data.shareInfo.otherParam = "id=".concat(t.options.id))) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1200
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    setInfo: function() {
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, a = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, t = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
        this.setData({
            info: e,
            goods: a,
            received_info: t
        });
    },
    tuUrl: function() {
        wx.navigateTo({
            url: "/packageI/warehouseFarm/warehouseFarmGiftLog/warehouseFarmGiftLog?tag=1"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function(e) {
        var a = {};
        return e && "button" == e.from || "creat" == this.options.mode ? (a.title = this.data.shareInfo.title, 
        a.imageUrl = this.data.shareInfo.imgUrl, a.path = "/packageI/warehouseFarm/warehouseFarmIndex/warehouseFarmIndex?" + this.data.shareInfo.otherParam) : a.path = "/packageI/warehouseFarm/warehouseFarmGiftDetail/warehouseFarmGiftDetail?" + this.data.shareInfo.otherParam, 
        a;
    }
});